package pCloud.transport;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class SocketClientTransportHandle implements EndPointTransportHandle{

	Socket conn; 
	String hostName;
	int port; 
	ObjectInputStream input;
	ObjectOutputStream output; 
	
	
	@Override
	public void initalize(String hostName, int port) throws Exception {
		this.hostName = hostName;
		this.port = port; 
		
	}
	
	@Override
	public TransportHandle accept() throws IOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public TransportHandle connect() throws IOException {
		conn = new Socket();
		System.out.println("Connecting to "+hostName+":"+port);
		conn.connect(new InetSocketAddress(hostName, port));
		
		return new SocketTransportHandle(conn);
		
	}	


}
